package com.tc.rocketmq.controller;

import com.tc.rocketmq.basic.SpringProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: tianchao
 * @Date: 2021/9/4 21:43
 * @Description:
 */
@RestController
@RequestMapping("/MQTest")
public class MqTestController {

    String topic = "BootTestTopic2";
    @Autowired
    private SpringProducer producer;
    @GetMapping("/sendMessage")
    public String sendMessage(String message){
        producer.sendMessage(topic, message);
        return "消息发送成功";
    }
    @GetMapping("/sendTranMessage")
    public String sendTranMessage(String message){
        producer.sendMessageInTransaction(topic, message);
        return "消息发送成功";
    }


}
